package com.example.mydownloader.mymodule.encrypt

import javax.crypto.spec.SecretKeySpec


/**
 * @Author: Wallace
 * @Description:
 * @Date: 2021/12/31 23:55
 * @Modified By:
 */
data class AESKey(val key: ByteArray, val iv: ByteArray) {

    fun getSecretKeySpec(): SecretKeySpec {
        return SecretKeySpec(this.key, AESCryptUtil.AES_ALGORITHM)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as AESKey

        if (!key.contentEquals(other.key)) return false
        if (!iv.contentEquals(other.iv)) return false

        return true
    }

    override fun hashCode(): Int {
        var result = key.contentHashCode()
        result = 31 * result + iv.contentHashCode()
        return result
    }
}